package demo.fah.modele;

public enum StatutActivite {
    INCONNU("INCONNU"), ANALYSE("Analyse"), TEST("Tests unitaires"), LIVRABLE("Livrable"), LIVREE("Livrer");

    private final String description;

    private StatutActivite(String description) {
        this.description = description;
    }

    @Override
    public String toString() {
        return description;
    }

    public static StatutActivite reverse(String description) {
        final StatutActivite[] statutActivites = StatutActivite.values();
        StatutActivite valueOf = null;

        if (description != null) {
            String description2 = description;
            final int indexOf = description.indexOf("---> ");
            if (indexOf >= 0) {
                description2 = new String(description.substring(indexOf + 5));
            }

            for (final StatutActivite statutActivite : statutActivites) {
                if (statutActivite.description.equals(description2)) {
                    valueOf = statutActivite;
                    break;
                }
            }
        }

        if (valueOf == null) {
            valueOf = StatutActivite.INCONNU;
        }

        return valueOf;
    }

}
